Skip to content

Replace Android-only WindowInsets.isImeVisible with expect/actual for iOS compatibility#6795

Open
michaelabon wants to merge 2 commits intostreetcomplete:masterfrom
michaelabon:fix/address-input-ios-compat
Open

Replace Android-only WindowInsets.isImeVisible with expect/actual for iOS compatibility#6795
michaelabon wants to merge 2 commits intostreetcomplete:masterfrom
michaelabon:fix/address-input-ios-compat

Conversation

@michaelabon
Copy link
Copy Markdown
Contributor

AnAddressNumberInput.kt in commonMain uses WindowInsets.isImeVisible, which is a Jetpack Compose Android-only API not available in Compose Multiplatform 1.10.0 for iOS targets.

This introduces a small isImeVisible() expect/actual function in ui/util/:

  • commonMain: expect declaration
  • androidMain: delegates to WindowInsets.isImeVisible (preserving existing behaviour)
  • iosMain: returns false for now (proper keyboard visibility detection can be wired up later)

Follows the existing expect/actual conventions in the codebase (e.g. util/locale/, util/platform/).

Part of the iOS port effort (#5421).

… iOS compatibility

AnAddressNumberInput.kt used `WindowInsets.isImeVisible`, which is a
Jetpack Compose Android-only API unavailable in Compose Multiplatform
for iOS targets.

Introduce an `isImeVisible()` expect/actual function in ui/util/:
- commonMain: expect declaration
- androidMain: delegates to WindowInsets.isImeVisible
- iosMain: returns false (keyboard detection can be added later)

Part of the iOS port effort (streetcomplete#5421).
Copy link
Copy Markdown
Member

@westnordost westnordost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this one is difficult.

The "switch keyboard between alphanumeric and numeric" button is only shown when the keyboard is visible. This button is important to input the house number correctly, e.g. for house numbers like "53b".

So, just returning false on iOS is not going to cut it. On iOS, there is an API for that, one can subscribe to

and then update a state accordingly. Currently I don't have this project set up on a mac yet so without testing an implementation it's no use. Do you?

@westnordost
Copy link
Copy Markdown
Member

(Alternative to implementing it right away would be to return TODO() instead of false, so that the issue can be postponed but will not be forgotten.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants